#include "trap.h"
#include "instr_def.h"
#include "instr_test.h"
    .set reorder
    .set noat
    .globl main
    .text
main:
    li $k1, 0x0    
    # AND 1
    li $s1, 0x0
    nop
    nop
    AND_TEST(0x80613360, 0x42adf91d, 0x00213100) # 1 
    nop
    nop
    AND_TEST(0x555b05c6, 0x555b05c6, 0x555b05c6) # 2 
    nop
    nop
    AND_TEST(0x1257c7a6, 0x24ac79b4, 0x000441a4) # 3 
    nop
    nop
    AND_TEST(0xd0439d20, 0x210c4488, 0x00000400) # 4 
    nop
    nop
    AND_TEST(0x00000000, 0x7d54a866, 0x00000000) # 5 
    nop
    nop
    AND_TEST(0x9fcc8a42, 0x00000000, 0x00000000) # 6 
    nop
    nop
    AND_TEST(0xeca485a1, 0xacbd1234, 0xaca40020) # 7 
    nop
    nop
    AND_TEST(0x0913c7b8, 0x6c5f982c, 0x08138028) # 8 
    nop
    nop
    AND_TEST(0x45d5eda8, 0x2890ffb0, 0x0090eda0) # 9 
    nop
    nop
    AND_TEST(0x2a19dd40, 0xa87971e0, 0x28195140) # 10 
    nop
    nop
    AND_TEST(0x8dededee, 0x2dededee, 0x0dededee) # 11 
    nop
    nop
    AND_TEST(0xe4b62124, 0x6f1772b8, 0x64162020) # 12 
    nop
    nop
    AND_TEST(0xc9c9c9ca, 0x5dededee, 0x49c9c9ca) # 13 
    nop
    nop
    AND_TEST(0xeca485a1, 0xeca485a1, 0xeca485a1) # 14 
    nop
    nop
    AND_TEST(0x00000000, 0x80000000, 0x00000000) # 15 
    li $k0, 1

    # ANDI 2
    li $s1, 0x0
    nop
    nop
    ANDI_TEST(0x80613360, 0x00003100, 0xf91d) # 1 
    nop
    nop
    ANDI_TEST(0x555b05c6, 0x000005c6, 0xf5c6) # 2 
    nop
    nop
    ANDI_TEST(0x1257c7a6, 0x000041a4, 0x79b4) # 3 
    nop
    nop
    ANDI_TEST(0xd0439d20, 0x00000400, 0x4488) # 4 
    nop
    nop
    ANDI_TEST(0x00000000, 0x00000000, 0xa866) # 5 
    nop
    nop
    ANDI_TEST(0x9fcc8a42, 0x00000000, 0x0000) # 6 
    nop
    nop
    ANDI_TEST(0xeca485a1, 0x00000020, 0x1234) # 7 
    nop
    nop
    ANDI_TEST(0x0913c7b8, 0x00008028, 0x982c) # 8 
    nop
    nop
    ANDI_TEST(0x45d5eda8, 0x0000eda0, 0xffb0) # 9 
    nop
    nop
    ANDI_TEST(0x2a19dd40, 0x00005140, 0x71e0) # 10 
    nop
    nop
    ANDI_TEST(0x8dededee, 0x0000edee, 0xedee) # 11 
    nop
    nop
    ANDI_TEST(0xe4b62124, 0x00002020, 0x72b8) # 12 
    nop
    nop
    ANDI_TEST(0xc9c9c9ca, 0x0000c9ca, 0xedee) # 13 
    nop
    nop
    ANDI_TEST(0xeca41a58, 0x00000000, 0x85a1) # 14 
    nop
    nop
    ANDI_TEST(0x00000000, 0x00000000, 0x8000) # 15 
    li $k0, 2

    # LUI 3
    li $s1, 0x0
    nop
    nop
    LUI_TEST(0x7fff0000, 0x7fff) # 1
    nop
    nop
    LUI_TEST(0x80000000, 0x8000) # 2
    nop
    nop
    LUI_TEST(0x12340000, 0x1234) # 3
    nop
    nop
    LUI_TEST(0xecea0000, 0xecea) # 4
    nop
    nop
    LUI_TEST(0x99990000, 0x9999) # 5
    nop
    nop
    LUI_TEST(0x00000000, 0x0000) # 6
    nop
    nop
    LUI_TEST(0x01c30000, 0x01c3) # 7
    nop
    nop
    LUI_TEST(0x00200000, 0x0020) # 8
    nop
    nop
    LUI_TEST(0xffff0000, 0xffff) # 9
    nop
    nop
    LUI_TEST(0xbcf00000, 0xbcf0) # 10
    nop
    nop
    LUI_TEST(0x665c0000, 0x665c) # 11
    nop
    nop
    LUI_TEST(0x29570000, 0x2957) # 12
    nop
    nop
    LUI_TEST(0x73340000, 0x7334) # 13
    nop
    nop
    LUI_TEST(0x81860000, 0x8186) # 14
    nop
    nop
    LUI_TEST(0xbbff0000, 0xbbff) # 15
    nop
    nop
    li $k0, 3

    # NOR 4
    li $s1, 0x0
    nop
    nop
    NOR_TEST(0x80613360, 0x42adf91d, 0x3d120482) # 1 
    nop
    nop
    NOR_TEST(0x555b05c6, 0x555b05c6, 0xaaa4fa39) # 2 
    nop
    nop
    NOR_TEST(0x1257c7a6, 0x24ac79b4, 0xc9000049) # 3 
    nop
    nop
    NOR_TEST(0xd0439d20, 0x210c4488, 0x0eb02257) # 4 
    nop
    nop
    NOR_TEST(0x00000000, 0x7d54a866, 0x82ab5799) # 5 
    nop
    nop
    NOR_TEST(0x9fcc8a42, 0x00000000, 0x603375bd) # 6 
    nop
    nop
    NOR_TEST(0xeca485a1, 0xacbd1234, 0x1342684a) # 7 
    nop
    nop
    NOR_TEST(0x0913c7b8, 0x6c5f982c, 0x92a02043) # 8 
    nop
    nop
    NOR_TEST(0x45d5eda8, 0x2890ffb0, 0x922a0047) # 9 
    nop
    nop
    NOR_TEST(0x2a19dd40, 0xa87971e0, 0x5586021f) # 10 
    nop
    nop
    NOR_TEST(0x8dededee, 0x2dededee, 0x52121211) # 11 
    nop
    nop
    NOR_TEST(0xe4b62124, 0x6f1772b8, 0x10488c43) # 12 
    nop
    nop
    NOR_TEST(0xc9c9c9ca, 0x5dededee, 0x22121211) # 13 
    nop
    nop
    NOR_TEST(0xeca485a1, 0xeca485a1, 0x135b7a5e) # 14 
    nop
    nop
    NOR_TEST(0x00000000, 0x80000000, 0x7fffffff) # 15 
    li $k0, 4

    # OR 5
    li $s1, 0x0
    nop
    nop
    OR_TEST(0x80613360, 0x42adf91d, 0xc2edfb7d) # 1 
    nop
    nop
    OR_TEST(0x555b05c6, 0x555b05c6, 0x555b05c6) # 2 
    nop
    nop
    OR_TEST(0x1257c7a6, 0x24ac79b4, 0x36ffffb6) # 3 
    nop
    nop
    OR_TEST(0xd0439d20, 0x210c4488, 0xf14fdda8) # 4 
    nop
    nop
    OR_TEST(0x00000000, 0x7d54a866, 0x7d54a866) # 5 
    nop
    nop
    OR_TEST(0x9fcc8a42, 0x00000000, 0x9fcc8a42) # 6 
    nop
    nop
    OR_TEST(0xeca485a1, 0xacbd1234, 0xecbd97b5) # 7 
    nop
    nop
    OR_TEST(0x0913c7b8, 0x6c5f982c, 0x6d5fdfbc) # 8 
    nop
    nop
    OR_TEST(0x45d5eda8, 0x2890ffb0, 0x6dd5ffb8) # 9 
    nop
    nop
    OR_TEST(0x2a19dd40, 0xa87971e0, 0xaa79fde0) # 10 
    nop
    nop
    OR_TEST(0x8dededee, 0x2dededee, 0xadededee) # 11 
    nop
    nop
    OR_TEST(0xe4b62124, 0x6f1772b8, 0xefb773bc) # 12 
    nop
    nop
    OR_TEST(0xc9c9c9ca, 0x5dededee, 0xddededee) # 13 
    nop
    nop
    OR_TEST(0xeca485a1, 0xeca485a1, 0xeca485a1) # 14 
    nop
    nop
    OR_TEST(0x00000000, 0x80000000, 0x80000000) # 15 
    li $k0, 5

    # ORI 6
    li $s1, 0x0
    nop
    nop
    ORI_TEST(0x80613360, 0x8061bff9, 0xadf9) # 1 
    nop
    nop
    ORI_TEST(0x555b05c6, 0x555b5fde, 0x5b5c) # 2 
    nop
    nop
    ORI_TEST(0x1257c7a6, 0x1257efb6, 0x2ab4) # 3 
    nop
    nop
    ORI_TEST(0xd0439d20, 0xd043dda8, 0x4488) # 4 
    nop
    nop
    ORI_TEST(0x00000000, 0x00007da6, 0x7da6) # 5 
    nop
    nop
    ORI_TEST(0x9fcc8a42, 0x9fcc8a42, 0x0000) # 6 
    nop
    nop
    ORI_TEST(0xeca485a1, 0xeca4adb5, 0xac34) # 7 
    nop
    nop
    ORI_TEST(0x0913c7b8, 0x0913efbc, 0x6c2c) # 8 
    nop
    nop
    ORI_TEST(0x45d5eda8, 0x45d5edb8, 0x28b0) # 9 
    nop
    nop
    ORI_TEST(0x2a19dd40, 0x2a19fd70, 0xa870) # 10 
    nop
    nop
    ORI_TEST(0x8dededee, 0x8dededee, 0x2dee) # 11 
    nop
    nop
    ORI_TEST(0xe4b62124, 0xe4b663bc, 0x62b8) # 12 
    nop
    nop
    ORI_TEST(0xc9c9c9ca, 0xc9c9dfee, 0x5eee) # 13 
    nop
    nop
    ORI_TEST(0xeca485a1, 0xeca4edfb, 0xec5a) # 14 
    nop
    nop
    ORI_TEST(0x00000000, 0x00008000, 0x8000) # 15 
    li $k0, 6

    # XOR 7
    li $s1, 0x0
    nop
    nop
    XOR_TEST(0x80613360, 0x42adf91d, 0xc2ccca7d) # 1 
    nop
    nop
    XOR_TEST(0x555b05c6, 0x555b05c6, 0x00000000) # 2 
    nop
    nop
    XOR_TEST(0x1257c7a6, 0x24ac79b4, 0x36fbbe12) # 3 
    nop
    nop
    XOR_TEST(0xd0439d20, 0x210c4488, 0xf14fd9a8) # 4 
    nop
    nop
    XOR_TEST(0x00000000, 0x7d54a866, 0x7d54a866) # 5 
    nop
    nop
    XOR_TEST(0x9fcc8a42, 0x00000000, 0x9fcc8a42) # 6 
    nop
    nop
    XOR_TEST(0xeca485a1, 0xacbd1234, 0x40199795) # 7 
    nop
    nop
    XOR_TEST(0x0913c7b8, 0x6c5f982c, 0x654c5f94) # 8 
    nop
    nop
    XOR_TEST(0x45d5eda8, 0x2890ffb0, 0x6d451218) # 9 
    nop
    nop
    XOR_TEST(0x2a19dd40, 0xa87971e0, 0x8260aca0) # 10 
    nop
    nop
    XOR_TEST(0x8dededee, 0x2dededee, 0xa0000000) # 11 
    nop
    nop
    XOR_TEST(0xe4b62124, 0x6f1772b8, 0x8ba1539c) # 12 
    nop
    nop
    XOR_TEST(0xc9c9c9ca, 0x5dededee, 0x94242424) # 13 
    nop
    nop
    XOR_TEST(0xeca485a1, 0xeca485a1, 0x00000000) # 14 
    nop
    nop
    XOR_TEST(0x00000000, 0x80000000, 0x80000000) # 15 
    li $k0, 7
    
    # XORI 8
    li $s1, 0x0
    nop
    nop
    XORI_TEST(0x80613360, 0x80619e99, 0xadf9) # 1 
    nop
    nop
    XORI_TEST(0x555b05c6, 0x555b5e9a, 0x5b5c) # 2 
    nop
    nop
    XORI_TEST(0x1257c7a6, 0x1257ed12, 0x2ab4) # 3 
    nop
    nop
    XORI_TEST(0xd0439d20, 0xd043d9a8, 0x4488) # 4 
    nop
    nop
    XORI_TEST(0x00000000, 0x00007da6, 0x7da6) # 5 
    nop
    nop
    XORI_TEST(0x9fcc8a42, 0x9fcc8a42, 0x0000) # 6 
    nop
    nop
    XORI_TEST(0xeca485a1, 0xeca42995, 0xac34) # 7 
    nop
    nop
    XORI_TEST(0x0913c7b8, 0x0913ab94, 0x6c2c) # 8 
    nop
    nop
    XORI_TEST(0x45d5eda8, 0x45d5c518, 0x28b0) # 9 
    nop
    nop
    XORI_TEST(0x2a19dd40, 0x2a197530, 0xa870) # 10 
    nop
    nop
    XORI_TEST(0x8dededee, 0x8dedc000, 0x2dee) # 11 
    nop
    nop
    XORI_TEST(0xe4b62124, 0xe4b6439c, 0x62b8) # 12 
    nop
    nop
    XORI_TEST(0xc9c9c9ca, 0xc9c99724, 0x5eee) # 13 
    nop
    nop
    XORI_TEST(0xeca485a1, 0xeca469fb, 0xec5a) # 14 
    nop
    nop
    XORI_TEST(0x00000000, 0x00008000, 0x8000) # 15 
    li $k0, 8
    li $k1, 0x12345678
    HIT_GOOD_TRAP		# stop temu

res_error: 
    li $s1, 0x11111111
    HIT_BAD_TRAP		# stop temu
